//
//  UrlIconNode.hpp
//  client
//
//  Created by ming on 2018/10/29.
//

#ifndef UrlIconWidget_hpp
#define UrlIconWidget_hpp

#include "cocos2d.h"
#include "ui/CocosGUI.h"
#include "Gif/GifBase.h"
#include "CCLuaEngine.h"
USING_NS_CC;

class UrlIconWidget:public ui::Widget {
public:
    virtual ~UrlIconWidget();
    UrlIconWidget();
    static UrlIconWidget * create();
    void loadFromUrl(const char * url, const char * cacheName);
    void setLuaScriptCallback(LUA_FUNCTION handler);
    void cancelLuaScriptCallback();
    Node * getVirtualRenderer();
    bool isGif(){return _gif != nullptr;}
   
protected:
    void _onHttpResponse(cocos2d::network::HttpClient *sender, cocos2d::network::HttpResponse *response);
    void _runLuaCallBack(bool trueOrFalse);
    void _onDownLoadSucceed();
public:
    LUA_FUNCTION _handler;
    std::string _url;
    std::string _cachePath;
    cocos2d::ui::ImageView * _imageView;
    GifBase * _gif;
    
};

#endif /* UrlIconWidget_hpp */
